package cn.skcks.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class RestfulController {

	// http://localhost:18080/add?a=1&b=1
	@RequestMapping(value = "/add")
	public String add(@RequestParam("a") int a, int b, Model model) {
		model.addAttribute("msg", "结果为: " + (a + b));
		return "test";
	}

	// http://127.0.0.1:18080/add/10086/-10000
	@RequestMapping(value = "/add/{a}/{b}",method = RequestMethod.GET)
	public String restfulAdd(@PathVariable int a, @PathVariable int b, Model model) {
		model.addAttribute("msg", "结果为: " + (a + b));
		return "test";
	}
}